<template>
	<view class="u-page">
		<view class="header"></view>
		<view class="content">
			<view class="storeBalance">
				<view class="wallet">
					<view class="lab"><span>余额</span> </view>
					<view class="walletList" @click="goPage('/pages/user/wallet')"><span>资金明细</span> </view>

				</view>
				<view class="balance">￥{{datas.balance + datas.wallet}}</view>
				<view class="but"><button type="warn" size="mini"
						@click="goPage('/pages/user/wallet/withdrawal')">提现至微信</button></view>
			</view>
			<view class="title">
				我的资产分布
			</view>
			<view class="charts-box">

				<qiun-data-charts type="ring" :opts="option" :chartData="chartData" background="none" />
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				column: '',
				datas: {},
				balance: '',
				chartData: {
					series: [{
						data: [{
								name: '新疆石榴红了主图餐厅',
								value: 500
							},
							{
								name: '浦东梁子酒吧',
								value: 200
							}, {
								name: '新疆石榴红了主图餐厅',
								value: 500
							}
						]
					}]
				},
				option: {
					title: {
						name: '资产总计'
					},

				}
			}
		},
		onLoad(data) {
			this.usersList();
		},
		methods: {
			goPage(url) {
				uni.navigateTo({
					url: url
				})

			},
			goback() {
				uni.navigateBack({
					delta: 1
				})
			},
			async usersList() {
				const users = await this.GQL({
					"operationName": "allSlUsers",
					"query": "query allSlUsers($filter: SlUserFilter) { allSlUsers(filter:$filter) { nodes {balance wallet  uid isStore } } }",
					"variables": {
						"filter": {
							"uid": {
								"equalTo": uni.getStorageSync('userData').uid
							}
						}
					}
				})
				console.log('user', users)
				if (users.data.allSlUsers.nodes != '') {
					if (users.data.allSlUsers.nodes[0].jurisdiction == 1) {
						this.column = '4';
					} else if (users.data.allSlUsers.nodes[0].jurisdiction == 2) {
						this.column = '3';
					} else {
						this.column = '1';
					}
					this.datas = users.data.allSlUsers.nodes[0]
				}
			},


		}
	}
</script>

<style lang="scss">
	.u-page {
		background-color: #FBFCFE;
	}

	.charts-box {
		width: 100%;
		height: 300px;
		margin-top: 30px;
	}

	.header {
		width: 100%;
		height: 150px;
		/* color: #FFFFFF; */
		background: linear-gradient(#C7171E, #f0f2f5);
		/* 标准的语法 */

	}

	.content {
		position: relative;
		top: -160px;

		border-radius: 5px;
		margin: 15px;

		.title {
			text-align: center;
			margin-top: 30px;
		}

		.storeBalance {
			margin-top: 30px;
			border-radius: 10px;
			background-color: #FFFFFF;
			height: 150px;
			text-align: center;

			.walletList {
				text-align: right;
				margin-right: 10px;
				height: 43px;
				margin-top: -35px;
				font-size: 12px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #767B8D;
				line-height: 16px;
			}

			.lab {
				padding: 20px 0px;
				font-size: 18px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #767B8D;
				line-height: 16px;
			}

			.balance {
				padding: 10px 0px 20px 0px;
				font-size: 24px;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				color: #C7171E;
				line-height: 16px;
			}
		}

	}
</style>
